package edu.weber.campbell.struts2;

import java.sql.*;

public class SQLDemo {
	private String message;
	
	public String execute(){
		try{
			message = runQuery();
		}catch(Exception e){
			message="failed";
		}
	 return "Success";
	}
	public String runQuery()throws SQLException{
//		Connection connection = null;
		String result = "hello";
//		try{
//			DriverManager.registerDriver(new com.mysql.jdbc.Driver());
//			connection = DriverManager.getConnection("jdbc:mysql://icarus.cs.weber.edu:3306/reservations", "reservations", "Hello912");
//			
//			Statement sqlStatement = connection.createStatement();
//			ResultSet sqlResult = sqlStatement.executeQuery("select * from USER");
//			System.out.println("\nUserID\tUserFirstName\tUserLastName\tUserPassword\tUserRoll\tUserStatus\tUserComments\tUserPhoneNumber\tUserName\n");
//			
//			while(sqlResult.next())
//			{
//				result = (sqlResult.getString(1)+"\t"+sqlResult.getString(2)+"\t\t"+sqlResult.getString(3)+"\t\t"+sqlResult.getString(4)
//						+"\t\t"+sqlResult.getString(5)+"\t\t"+sqlResult.getString(6)+"\t\t"+sqlResult.getString(7)+"\t\t"+sqlResult.getString(8)
//						+"\t\t"+sqlResult.getString(9));
//			}
//			sqlResult.close();
//			sqlStatement.close();
//						
//		}catch(Exception e){
//			System.out.println("Exception : " + e);
//			
//		}finally{
//			connection.close();
//		}
		return result;
	}
		
    public String getMessage() {
        return message;
    }
  
    public void setMessage(String message) {
        this.message = message;
    }
}
